﻿function ShowTime(timeId) {
    var weerk = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
    var date = new Date();
    var hr = date.getHours();
    if (hr < 10) {
        hr = "0" + hr;
    }
    var minutes = date.getMinutes();
    if (minutes < 10) {
        minutes = "0" + minutes;
    }
    var seconds = date.getSeconds();
    if (seconds < 10) {
        seconds = "0" + seconds;
    }
    var dt = date.getFullYear() + "年" + (date.getMonth() + 1) + "月" + date.getDate() + "日";
    var time = hr + ":" + minutes + ":" + seconds;
    //$(timeId).text(dt + " " + time + "" + weerk[date.getDay()]);
    document.getElementById(timeId).innerText = dt + " " + time + " " + weerk[date.getDay()];
    setTimeout("ShowTime('" + timeId + "')", 1000);
}

/*日期转换*/
function showTimeIt(Dtime, isLang) {
    var NewDtime = eval('new ' + (Dtime.replace(/\//g, '')));
    return formatDate(NewDtime, isLang);
}
/*日期格式转换*/
function formatDate(dt, isLang) {
    //new Date().
    var year = dt.getFullYear();
    var month = dt.getMonth() + 1;
    if (month < 10) {
        month = "0" + month;
    }
    var date = dt.getDate();
    if (date < 10) {
        date = "0" + date;
    }
    var hour = dt.getHours();
    if (hour < 10) {
        hour = "0" + hour;
    }
    var minute = dt.getMinutes();
    if (minute < 10) {
        minute = "0" + minute;
    }
    var second = dt.getSeconds();
    if (second < 10) {
        second = "0" + second;
    }
    if (isLang) {
        return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;
    }
    return year + "-" + month + "-" + date;
}
/*日期格式转换*/
function formatDate1(dt) {
    //new Date().
    var year = dt.getFullYear();
    var month = dt.getMonth() + 1;
    if (month < 10) {
        month = "0" + month;
    }
    var date = dt.getDate();
    if (date < 10) {
        date = "0" + date;
    }
    var hour = dt.getHours();
    if (hour < 10) {
        hour = "0" + hour;
    }
    var minute = dt.getMinutes();
    if (minute < 10) {
        minute = "0" + minute;
    }
    return year + "-" + month + "-" + date + " " + hour + ":" + minute;
}

/*
    * 日期比较大小
    @ dt1 日期一
    @ dt2 日期二
*/
function CompareDate(dt1, dt2) {
    if (dt1.getTime() >= dt2.getTime()) {
        return false;
    }
    return true;
}